import express from 'express'
import { getResult, likeSql, listSql } from '../../../util/operateSql.js';
import {getAccount} from '../../../middleWare/user/index.js'

var router = express.Router();
const TABLE1 = 'activity_master.mini_tabbar'
router.get('/tabbarMenu',getAccount ,async (req,res,next) => {
  try {
    const user = req.master
    
    const condition = {orderBy:'sort',sort:'asc',enable: 1}
    if (user.is_manage) {
      condition.is_manage = 1
    }
    
    const sql = likeSql(TABLE1,condition,'=')
    
    const rows = await getResult(sql)
    res.json(req.app.locals.success(rows))
  } catch (error) {
		console.log('error: ', error);
    
    
    res.json(req.app.locals.error(error))
  }
})


export default router